﻿using B.Z.BasicData.Domain.Entity.Excused;
using B.Z.BasicData.ErrorCode;
using B.Z.BasicData.Infrastructure;
using MediatR;

namespace B.Z.BasicData.API.Read.Application.Excused
{
    public class ExcusedTypeQueryCommandHandler : IRequestHandler<ExcusedTypeQueryCommand, APIResult<List<T_ExcusedType>>>
    {
        private readonly IBaseRepository<T_ExcusedType> typeRepository;

        public ExcusedTypeQueryCommandHandler(IBaseRepository<T_ExcusedType> typeRepository)
        {
            this.typeRepository = typeRepository;
        }

        public Task<APIResult<List<T_ExcusedType>>> Handle(ExcusedTypeQueryCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<T_ExcusedType>> result = new APIResult<List<T_ExcusedType>>();
            result.Code = APIEnum.ok;
            result.Message = "获取成功";
            var list = typeRepository.GetAll().ToList();
            result.Data = list;
            return Task.FromResult(result);
        }
    }
}
